# !/usr/bin/env python
# coding=utf-8
# @Time    : 2018/7/19 10:22
# @Author  : 6imensiva
# @Site    : https://gitee.com/dimensiva/rpc_dao.git
# @File    : insurance_types_list.py
# @Software: PyCharm
# @Version: 2.7.5
from db import insurance_types_list
from utils import my_decorator
from idl_output.ttypes import InsuranceTypesList


@my_decorator.handle_exception()
def get_tpic_map():
	orm_data = insurance_types_list.get_tpic_map()
	thrift_map = {}
	for i in orm_data:
		thrift_data = InsuranceTypesList(riskCode=i.riskCode, riskName=i.riskName,
		                                 insuredAmount=i.insuredAmount, status=i.status,
		                                 insuranceCode=i.insuranceCode, insurTypeCode=i.insur_type_code)
		thrift_map[i.insur_type_code] = thrift_data
	return thrift_map


@my_decorator.handle_exception()
def get_clpc_map():
	orm_data = insurance_types_list.get_clpc_map()
	thrift_map = {}
	for i in orm_data:
		thrift_data = InsuranceTypesList(riskCode=i.riskCode, riskName=i.riskName,
		                                 insuredAmount=i.insuredAmount, status=i.status,
		                                 insuranceCode=i.insuranceCode, insurTypeCode=i.insur_type_code)
		thrift_map[i.insur_type_code] = thrift_data
	return thrift_map


@my_decorator.handle_exception()
def get_taic_map():
	orm_data = insurance_types_list.get_taic_map()
	thrift_map = {}
	for i in orm_data:
		thrift_data = InsuranceTypesList(riskCode=i.riskCode, riskName=i.riskName,
		                                 insuredAmount=i.insuredAmount, status=i.status,
		                                 insuranceCode=i.insuranceCode, insurTypeCode=i.insur_type_code)
		thrift_map[i.riskCode] = thrift_data
	return thrift_map
